home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / Biomorph 0.77 / Biomorph src / offscreen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-16  |  961 b   |  49 lines  |  [TEXT/ALFA]

  1. #include <MacHeaders>
  2. #include "constants.h"
  3. #include "globals.h"
  4.  
  5. /*********************
  6. ** SetupOffscreen()
  7. **
  8. ** initializes the offscreen bitmap buffer.
  9. **********************/
  10. void SetupOffscreen(void)
  11. {
  12.     GrafPtr    savedPort;
  13.     
  14.     GetPort( &savedPort);
  15.     
  16.     gOffBM.rowBytes = 26;    // 208/8
  17.     SetRect( &gOffBM.bounds, 0,0, 208,208);
  18.     gOffBM.baseAddr = NewPtrClear( 26* 208);
  19.     if (gOffBM.baseAddr == NULL)
  20.     {
  21.         // error: we can't get offscreen bitmap
  22.         Error( kBitmapAllocErr, 0, 0, 0, stopIcon);
  23.         Cleanup();
  24.     }
  25.     // else I got the bitmap allocated
  26.     OpenPort( &gOffGP);
  27.     SetPortBits( &gOffBM);
  28.     gOffGP.portRect = gOffBM.bounds;
  29.  
  30.     SetPort(savedPort);
  31. } // SetupOffscreen()
  32.  
  33.  
  34. /**********************
  35. ** CleanupOffscreen()
  36. **
  37. ** disposes of everything we needed for
  38. ** the offscreen buffer.
  39. ***********************/
  40. void CleanupOffscreen(void)
  41. {
  42.     if (gOffGP.portBits.baseAddr != NULL)
  43.         DisposPtr( gOffGP.portBits.baseAddr);
  44.     
  45.     ExitToShell();
  46. } // CleanupOffscreen()
  47.  
  48.  
  49.